package com.thoughtworks.bytecode2class.constantpool;

import com.thoughtworks.bytecode2class.ClassReader;

public class Utf8Constant extends Constant {

    private int length;
    
    private StringBuilder builder = new StringBuilder();

    public Utf8Constant(ClassReader classReader) {
        super(classReader);
        length = classReader.forwardChar();
        for (int i = 0; i < length; i++) {
            builder.append((char) classReader.forward());
        }
    }

    public void description() {
        System.out.printf("[%d]Utf8Constant - %s%n", getCount(), getValue());
    }

    public String getValue() {
        return builder.toString();
    }
}
